package com.back.Mapper;
import com.back.Dao.User;

import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    // 查询所有
    @Select("select * from users")
    List<User> findAllUser();

    // 查询一行
    @Select("select * from users where id = #{id}")
    User findUserById(Integer id);

    // 删除
    @Delete("delete from users where id = #{id}")
    Integer DelUser(int id);

    //增加
    Integer addUser(User user);

    // 修改
    Integer updateUser(User user);

    @Select("select * from users where user_name = #{userName}")
    User selectByUserName(String userName);
    @Insert("insert into users (user_name, user_pwd) values (#{UserName}, #{UserPwd})")
    void insert(User user);

    @Update("UPDATE users SET token = #{token} WHERE id = #{id}")
    void updateToken(Integer id, String token);
    @Delete("UPDATE `internet`.`users`\n" +
            "SET `token` = NULL\n" +
            "WHERE `id` = #{id};")
    void deleteToken(Integer id);
}
